//
//  DzAlertHelper.m

#import "DzAlertHelper.h"
#import "LPPopup.h"
#import "AppDelegate.h"
@interface DzAlertHelper()

@property (nonatomic,strong) LPPopup *popUp;

@end

@implementation DzAlertHelper
+ (instancetype)sharedInstance{
    static id sharedSingleton = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        sharedSingleton = [[self alloc] init];
    });
    return sharedSingleton;
}
+(void)showMessage:(NSString *)Str
{
    if (Str.length <= 0) {
        return;
    }
    dispatch_async(dispatch_get_main_queue(), ^{
        [self showPopupMessage:Str toView:nil centerPoint:((AppDelegate*)[[UIApplication sharedApplication] delegate]).window.center];
    });
}

+ (void)showPopupMessage:(NSString *)message toView:(UIView *)view centerPoint:(CGPoint)point {
    if (view == nil) {
        view = ((AppDelegate*)[[UIApplication sharedApplication] delegate]).window;
    }
    DzAlertHelper *help=[DzAlertHelper sharedInstance];
    if (help.popUp) {
        [help.popUp removeFromSuperview];
        help.popUp = nil;
    }
    help.popUp = [LPPopup popupWithText:message];
    [help.popUp showInView:view centerAtPoint:point duration:kLPPopupDefaultWaitDuration completion:nil];
}
@end
